package com.telecom.controller;

import com.dahuatech.hutool.http.Method;
import com.dahuatech.icc.exception.ClientException;
import com.dahuatech.icc.oauth.http.DefaultClient;
import com.dahuatech.icc.oauth.http.IClient;
import com.dahuatech.icc.oauth.model.v202010.GeneralRequest;
import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
import com.telecom.common.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//spark cfce62f1-e191-41aa-a83d-479c4760d50e
@RestController
@RequestMapping("/evo-apigw/evo-accesscontrol/1.0.0")
public class EntranceGuardController {


    //新增按人授权
    @PostMapping("/card/accessControl/doorAuthority")
    public void doorAuthority() throws ClientException {
        IClient iClient = new DefaultClient();
        /**
         * 1、请求地址是统一网关入口，以 /evo-apigw 开头
         * 2、方法参见 @see com.dahuatech.hutool.http.Method
         */
        GeneralRequest generalRequest = new GeneralRequest("/evo-apigw/evo-oauth/1.0.0/oauth/public-key", Method.GET);
        // set http post body
//        generalRequest.body("json请求体");
        // set http get method param 例如?name=xiao&mobile=1xxx
//        generalRequest.form("key", "value");
        // set header
//        generalRequest.header("key", "value");
        // 发起请求处理应答
        GeneralResponse generalResponse =iClient.doAction(generalRequest, generalRequest.getResponseClass());
        System.out.println("generalResponse = " + generalResponse);
    }
}
